<template>
  <div class="nav-menu">
    <!-- 导航栏标题 -->
    <div class="logo">
      <img class="img" src="~@/assets/img/logo.png" alt="logo" />
      <span
        class="title single-line-text-overflow"
        :title="$t('navMenu.title')"
        >{{ $t('navMenu.title') }}</span
      >
    </div>
    <div class="main">
      <el-menu :default-active="defaultActive" :collapse="collapse">
        <menu-tree :user-menus="userMenus"></menu-tree>
      </el-menu>
    </div>
  </div>
</template>
<script setup lang="ts">
import { ref, computed, defineProps } from 'vue'
import { useStore } from '@/store'
import menuTree from './c-cpns/menu-tree.vue'
import { useRoute } from 'vue-router'
import { pathMapToMenu } from '@/utils/map-menus'
defineProps({
  collapse: {
    type: Boolean
  }
})
const routes = useRoute()
const store = useStore()
const userMenus = computed(() => store.state.login.userMenuInfo)
const currentPath = routes.path
const menu = pathMapToMenu(userMenus.value, currentPath)
const defaultActive = ref(menu.id + '')
</script>
<style scoped lang="less">
.nav-menu {
  height: 100%;
  background-color: #001529;
  .logo {
    display: flex;
    height: 28px;
    padding: 12px 10px 8px 10px;
    flex-direction: row;
    justify-content: flex-start;
    align-items: center;
    .img {
      height: 100%;
      margin: 0 10px;
    }
    .title {
      font-size: 16px;
      font-weight: 700;
      color: white;
    }
  }
  .main {
    .el-menu {
      border-right: none;
      --el-menu-bg-color: #0c2135;
      --el-menu-text-color: #b7bdc3;
      --el-menu-active-color: #0a60bd;
    }
  }
}
.el-menu-item:hover {
  color: #fff !important; //
  background-color: #0c2135 !important;
}

.el-menu-item.is-active {
  color: #fff !important;
  background-color: #0a60bd !important;
}
</style>
